package GameOntology;

import java.awt.event.KeyEvent;

public class Player extends Tank  {
    private String direction;

    public Player() {
    }

    public Player(String img, int x, int y,
                  String tankUp, String tankLeft, String tankRight, String tankDown,GameWindow gameWindow) {
        super(img, x, y, tankUp, tankLeft, tankRight, tankDown,gameWindow);
        this.setBulletImg("game\\img\\bullet_player.png");
        this.setTeam("player");
    }


    //移到与攻击的判断
    public void keyPressed(KeyEvent e) {
        switch (e.getKeyChar()){
            case 'w':
                direction="up";
                this.setMove(true);
                break;
            case 's':
                direction="down";
                this.setMove(true);
                break;
            case 'd':
                direction="right";
                this.setMove(true);
                break;
            case 'a':
                direction="left";
                this.setMove(true);
                break;
            case 'j':
                this.setAttack(true);
            default:break;
        }
    }
    public void keyReleased(KeyEvent e) {
        switch (e.getKeyChar()){
            case 'w':
            case 's':
            case 'd':
            case 'a':
                this.setMove(false);
                break;
            default:break;
        }
    }
    public void keyMove(){
        this.move(this.direction,this.isMove());
    }

}
